Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate the next steps to client side #34450

Merged

Conversation

rezkiy37
Copy link
Contributor

@rezkiy37 rezkiy37 commented Jan 12, 2024

Details

Generates an optimistic nextStep based on a current report status and other properties. Includes unit-tests that cover 100% of a main function - buildNextStep.

Fixed Issues

$ #28771
PROPOSAL: N/A

Tests

Note: we migrate next step prediction as much as possible. However, the app cannot predict all violations or some other complex states. So, the backend can respond with a little bit detailed next step or even another message like an error or warning. I describe all possible cases that we calculate on the client side in "Tests". Also, since we test how optimistic data works, I recommend to enable slow Internet or offline mode.

Pre requirements:

  1. Create/have 2 users at least. One of them is a member of workspaces. The 2nd one is an admin.
  2. Create/have 2 paid workspaces via OD: Collect and Control. The feature does not work for a free workspace.
  3. Use OD to manipulate with the workspaces.

1. Generates an optimistic nextStep once a report has been OPENED

1. Self review
  1. The member: opens a workspace chat.
  2. The member: requests money.
  3. The member: Verify that there is a next step with a comment: "Waiting for you to submit these expenses." and label is "Next Steps".
2. Scheduled submit enabled
  1. The admin: sets "Scheduled Submit" enabled via OD in the "Reports" section.
  2. The admin: selects each value one by one. The label is "Next Steps" and corresponding comments:
  • Daily: "These expenses are scheduled to automatically submit later today! No further action required!";
  • Weekly: "These expenses are scheduled to automatically submit on Sunday! No further action required!";
  • Twice a month: "These expenses are scheduled to automatically submit on the 1st and 16th of each month! No further action required!";
  • Monthly: "These expenses are scheduled to automatically submit on the [Selected report submission date] of each month! No further action required!";
  • Trip: "These expenses are scheduled to automatically submit at the end of your trip! No further action required!";
  • Manual: "Waiting for you to submit these expenses.";
  1. The member: requests money.
  2. The member: Verify that there is a next step with a corresponding comment mentioned above.
3. Self submitting prevented
  1. The admin: sets "Prevent Self-Approval" enabled via OD in the "Members" section > "Workflow Enforcement".
  2. The admin: requests money.
  3. The admin: Verify that there is a next step with a comment: "Oops! Looks like you're submitting to yourself. Approving your own reports is forbidden by your policy. Please submit this report to someone else or contact your admin to change the person you submit to." and label is "Next Steps".

2. Generates an optimistic nextStep once a report has been SUBMITTED

1. Self review
  1. Do steps: 1.3.
  2. The admin: clicks on a "Submit" button.
  3. The admin: Verify that there is a next step with a comment: "Waiting for you* to review these expenses." and label is "Next Steps".
2. Another reviewer
  1. Do steps: 1.1.
  2. The member: clicks on a "Submit" button.
  3. The member: Verify that there is a next step with a comment: "Waiting for [the admin's display name]* to approve these expenses." and label is "Next Steps".
3. Another owner
  1. Do steps: 1.1.
  2. The admin: clicks on a "Submit" button.
  3. The admin: Verify that there is a next step with a comment: "[the member's login]* is waiting for you to review these expenses." and label is "Next Steps" and label is "Next Steps". However, when you are not a manager a verb review is replaced with approve.

3. Generates an optimistic nextStep once a report has been APPROVED

1. Self review
  1. Do steps: 1.3 and 2.1.
  2. The admin: clicks on an "Approve" button.
  3. The admin: Verify that there is a next step with a comment: "Waiting for you* to review these expenses." and label is "Next Steps".
2. Another owner
  1. Do steps: 1.1 and 2.3.
  2. The admin: clicks on an "Approve" button.
  3. The admin: Verify that there is a next step with a comment: "No further action required!" and label is "Finished!".

4. Generates an optimistic nextStep once a report has been PAID

1. Paid with wallet
  1. Do steps: 1.1 and 2.3, 3.1 or 3.2.
  2. The admin: clicks on a "Pay elsewhere" button.
  3. The admin: Verify that there is a next step with a comment: "You have marked these expenses as paid." and label is "Finished!".
2. Paid outside of Expensify
  1. Do steps: 1.1 and 2.3, 3.1 or 3.2.
  2. The admin: clicks on a "Pay with Expensify" button.
  3. The admin: Verify that there is a next step with a comment: "You have marked these expenses as paid outside of Expensify." and label is "Finished!".
  • Verify that no errors appear in the JS console

Offline tests

Same as "Tests".

QA Steps

Same as "Tests".

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android.1.1.mp4
Android.1.2.Last.business.day.mp4
Android.1.3.mp4
Android: mWeb Chrome
Android.Chrome.1.1.mp4
Android.Chrome.1.2.Trip.mov
Android.Chrome.1.3.mp4
iOS: Native
IOS.1.1.mov
IOS.1.2.Last.business.day.mp4
IOS.1.3.mov
iOS: mWeb Safari
IOS.Safari.1.1.mov
IOS.Safari.1.2.Trip.mov
IOS.Safari.1.3.mov
MacOS: Chrome / Safari
Chrome.1.1.mp4
Chrome.1.2.Daily.mp4
Chrome.1.2.Monthly.3rd.mp4
Chrome.1.3.mov
Chrome.2.1.mov
Chrome.2.2.mov
Chrome.2.3.mov
MacOS: Desktop
Desktop.1.1.mp4
Desktop.1.2.Twice.a.month.mov
Desktop.1.3.mov

@rezkiy37 rezkiy37 marked this pull request as ready for review January 29, 2024 09:51
Copy link
Contributor

@allroundexperts allroundexperts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing well. Thanks for resolving the conflicts!

@melvin-bot melvin-bot bot requested a review from mountiny February 7, 2024 06:26
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will try to review tomorrow

src/libs/NextStepUtils.ts Outdated Show resolved Hide resolved
src/libs/NextStepUtils.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will try to review tomorrow

@rezkiy37 rezkiy37 requested a review from mountiny February 8, 2024 09:48
Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rezkiy37 ok couple comments

src/libs/actions/IOU.ts Outdated Show resolved Hide resolved
src/libs/actions/IOU.ts Outdated Show resolved Hide resolved
src/libs/actions/IOU.ts Outdated Show resolved Hide resolved
src/libs/actions/IOU.ts Outdated Show resolved Hide resolved
src/libs/actions/IOU.ts Outdated Show resolved Hide resolved
src/libs/NextStepUtils.ts Outdated Show resolved Hide resolved
src/libs/NextStepUtils.ts Show resolved Hide resolved
Comment on lines +269 to +277
// Another owner
if (!isOwner) {
optimisticNextStep.title = 'Finished!';
optimisticNextStep.message = [
{
text: 'No further action required!',
},
];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An approver could also be an admin who still needs to reimburse I think, how would this work in this case? It would show them they are done but they still need to pay it, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An approver could also be an admin...
Yes, could be. I think it is always an admin, it is not?

Based on a message that we get from the backend, it should be "No further action....". So, looks like it works properly.

Approved.mov

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok lets go with this and see if some issues will be reported!

Copy link
Contributor

@allroundexperts allroundexperts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see conflicts but still tested it so that this does not get blocked. It is working good. The chat switching is much snappier now.

@melvin-bot melvin-bot bot requested a review from mountiny February 9, 2024 00:02
@rezkiy37
Copy link
Contributor Author

rezkiy37 commented Feb 9, 2024

@mountiny, please take a look. I've applied the suggestions.

@mountiny
Copy link
Contributor

mountiny commented Feb 9, 2024

@allroundexperts was this a comment for wrong PR? 😄

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @rezkiy37 really appreciate it!

@allroundexperts thank you for testing!

Comment on lines +269 to +277
// Another owner
if (!isOwner) {
optimisticNextStep.title = 'Finished!';
optimisticNextStep.message = [
{
text: 'No further action required!',
},
];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok lets go with this and see if some issues will be reported!

@mountiny mountiny merged commit bb1fc0a into Expensify:main Feb 9, 2024
24 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Feb 9, 2024

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 1.4.40-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 failure ❌

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 1.4.40-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 failure ❌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants